package res

import (
	"net/http"

	"github.com/gin-gonic/gin"
)

const (
	SUCCESS = 200
	ERROR   = 500
	FADED   = 401
)

func Ok[T any](c *gin.Context, data T) {
	c.JSON(http.StatusOK, gin.H{
		"code": SUCCESS,
		"msg":  "success",
		"data": data,
	})
}

func Error[T any](c *gin.Context, data T) {
	c.JSON(http.StatusOK, gin.H{
		"code": ERROR,
		"msg":  "error",
		"data": data,
	})
}

func OkMsg(c *gin.Context, msg string) {
	c.JSON(http.StatusOK, gin.H{
		"code": SUCCESS,
		"msg":  msg,
	})
}

func ErrorMsg(c *gin.Context, msg string) {
	c.JSON(http.StatusOK, gin.H{
		"code": ERROR,
		"msg":  msg,
	})
}

func FadedMsg(c *gin.Context, msg string) {
	c.JSON(http.StatusOK, gin.H{
		"code": FADED,
		"msg":  msg,
	})
}
